<?php
class Zend_View_Helper_DateFormat
{
    public function DateFormat($date)
    {
        $date = strtotime($date);
        $q = QDateTime::getInstance();

        $min = $q->minuteDiffFromNow($date);
        if (1 > $min)
        {
            return $q->secondDiffFromNow($date).'秒前';
        }
        else if (60 > $min)
        {
            return floor($min).'分钟前'; 
        }
        else if (24 >= $q->hourDiffFromNow($date))
        {
            return floor($hour).'小时前';
        }
        else if (24 < $q->hourDiffFromNow($date) && 365 >= $q->dayDiffFromNow($date) )
        {
            return date('m月d日', $date); 
        }
        else
        {
            return date('Y年m月d日', $date);
        }
    }
}
